﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace GolfSigma.Inventory.Model
{
    public class GetSimilarTeeTimeRequest : IRequest
    {
        public UInt64 TeeTimeId { get; set; }
        public UInt64 SearchId { get; set; }

        /// <summary>
        /// Used to help track links your users clicked on.
        /// </summary>
        public string ExternalId { get; set; }

        public GetSimilarTeeTimeRequest()
        {
            TeeTimeId = 0;
            SearchId = 0;
        }
        public GetSimilarTeeTimeRequest(UInt64 searchId, UInt64 teeTimeId)
        {
            TeeTimeId = teeTimeId;
            SearchId = searchId;
        }

        public GetSimilarTeeTimeRequest(UInt64 searchId, UInt64 teeTimeId, string externalId) : this(searchId, teeTimeId)
        {
            ExternalId = externalId;
        }

        #region IRequest Members

        public string HttpVerb
        {
            get { return "GET"; }
        }

        public string HttpPath
        {
            get 
            {
                string uri = string.Format(
                    "/search/{0}/teetime/{1}/similar",
                    SearchId.ToString(),
                    TeeTimeId.ToString()
                    );

                // Append the externalId if it exists
                if (!string.IsNullOrEmpty(ExternalId))
                    uri += "?eId=" + System.Web.HttpUtility.UrlEncode(ExternalId);

                return uri;
            }
        }

        public IDictionary<string, string> HttpParameters
        {
            get { return null; }
        }

        public IDictionary<string, string> HttpHeaders
        {
            get { return null; }
        }

        #endregion
    }
    
    [XmlRoot("Response")]
    public class GetSimilarTeeTimeResponse
    {
        [XmlArray("TeeTimes")]
        public List<TeeTime> TeeTimes { get; set; }

        [XmlElement("ResponseMetadata")]
        public ResponseMetadata ResponseMetadata { get; set; }
    }
}
